﻿using System;
using System.Collections.Generic;
using System.Text;
using FloatingWindowTools.FloatingMapbasicWindow;
using MapInfo.MiPro.Interop;
using FloatingWindowTools.NormalFloatingWindow;
using System.Windows.Forms;

namespace FloatingWindowTools
{
    public static class Entry
    {
        public static void FloatMapbasicWindow()
        {
            Window mapbasicwindow = new Window(InteropServices.MapInfoApplication, (int)Window.WindowType.WIN_MAPBASIC);

            if (!mapbasicwindow.IsOpen)
            {
                // Open the mapbasic window.
                MapInfo.MiPro.Interop.InteropServices.MapInfoApplication.Do("Run Menu Command 608");
            }

            MapbasicWindowUI window = new MapbasicWindowUI(mapbasicwindow);
            window.Show();
        }

        public static void FloatWindow()
        {
            string ID = InteropServices.MapInfoApplication.Eval("FrontWindow()");
            Window windowtofloat = new Window(InteropServices.MapInfoApplication, Convert.ToInt32(ID));

            if (!windowtofloat.IsOpen)
            {
                MessageBox.Show("There is no selected window");
                return;
            }

            FloatingWindow window = new FloatingWindow(windowtofloat);

            Window mapinfoWindow = new Window(InteropServices.MapInfoApplication, (int)Window.WindowType.WIN_MAPINFO);
            window.Show(mapinfoWindow);
        }

        public static void ShowAbout()
        {
            AboutBox about = new AboutBox();
            about.ShowDialog();
        }

    }
}
